package com.chis.childcheck;

import com.chis.jm.bean.ChildSynInfoBean;
import com.chis.jm.bean.TriggerBean;
import com.chis.jm.pojo.Inoculation;
import com.chis.jmdatatimer.comm.JedisConnect;
import com.chis.jmdatatimer.comm.JedisSerializeUtil;
import org.apache.commons.lang.StringUtils;
import redis.clients.jedis.ShardedJedis;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 
 * @Description 
 * @Company zwx
 * @author wlj
 * @version 2019年08月05日
 */
public class KafkaGm {
    public static void main(String[] args) {
        ShardedJedis jedis = JedisConnect.getInstance().jedisPool.getResource();


        for(int i = 0 ; i < 6 ; i++){
            String key = "group_GP-TOPIC_GM_320500-"+i;
            jedis.select(0);
            String offset = jedis.get(key);
            if (StringUtils.isNotBlank(offset)) {
                jedis.select(1);
                Set<byte[]> value = jedis.zrangeByScore(key.getBytes(), 0, Double.valueOf(offset));
                for(byte[] serVal : value){
                    try {
                        TriggerBean triggerBean = (TriggerBean) JedisSerializeUtil.unserialize(serVal);
                        Map<Integer, Map<String, List<String>>> updateGuid = triggerBean.getUpdateGuid();
                        Map<Integer, Map<String, List<String[]>>> deleteGuid = triggerBean.getDeleteGuid();
                        if(updateGuid != null && updateGuid.size() > 0){
                            for(Integer j : updateGuid.keySet()){
                                System.out.println("=====================");
                                System.out.println("更新-内存库："+j);
                                Map<String, List<String>> map = updateGuid.get(j);
                                for(String s : map.keySet()){
                                    System.out.println("儿童编码："+s);
                                    List<String> list = map.get(s);
                                    if(list != null && list.size() > 0){
                                        StringBuilder sb = new StringBuilder();
                                        for(String ss : list){
                                            sb.append(",").append(ss);
                                        }
                                        System.out.println("业务编码："+sb.substring(1));
                                    }

                                }
                            }
                        }

                        if(deleteGuid != null && deleteGuid.size() > 0){
                            for(Integer j : deleteGuid.keySet()){
                                System.out.println("=====================");
                                System.out.println("删除-内存库："+j);
                                Map<String, List<String[]>> map = deleteGuid.get(j);
                                for(String s : map.keySet()){
                                    System.out.println("儿童编码："+s);
                                    List<String[]> list = map.get(s);
                                    if(list != null && list.size() > 0){
                                        StringBuilder sb = new StringBuilder();
                                        for(String[] ss : list){
                                            sb.append(",").append(ss[0]);
                                        }
                                        System.out.println("业务编码："+sb.substring(1));
                                    }

                                }
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
            }
        }




    }
}
